<template>
  <div class="home">
    <div class="header">
      登录页面
    </div>
   <div class="blocks">
     <input type="text" placeholder="输入手机号" v-model="user">
   </div>
   <div class="blocks">
     <input type="password" placeholder="输入手机号" v-model="password">
   </div>
   <div class="dl">
     <span @click="login">登录</span>
   </div>
  </div>
</template>

<script>
// 引入axios
import Axios from 'axios'

export default {
  data() {
    return {
      user:'',
      password:""
    }
  },
  methods: {
    login(){
      // 调用数据
      Axios.post('/login',{user:this.user,
      password:this.password}).then(res=>{
        console.log(res.data);
        // 判断
        if(res.data.code===200){
          // 本地存储
          localStorage.setItem("token",res.data.token)
          this.$router.push('/home')
        }
      })
    }
  },
}
</script>
<style lang="scss">
   *{
    padding: 0;
    margin: 0;
    list-style: none;
  }
  .header{
    height: 50px;
    line-height: 50px;
    text-align-last: center;
    background: #eee;
    font-size: 20px;
  }
  .blocks{
    padding-top: 10px;
    height: 50px;
    border-bottom: 1px solid #ccc;
  }
  .blocks input{
    padding: 0 20px;
    width: 100%;
    height: 100%;
      border: none;
  }
  .dl{
    width: 80%;
    height: 50px;
    margin-top: 30px;
  }
  .dl span{
    margin-left: 30px;
   border-radius: 12px;
   display: block;
   height: 80%;
   width: 100%;
   text-align: center;
   line-height: 50px;
   background: #666;
   color: #fff;
  }
</style>
